﻿


using ScottPlot;

namespace Common.Algorithm.Display;
internal class QuadTreeDisplay
{
    public static void Display(ScottPlot.IPlotControl myPlot)
    {
        //var plot = myPlot.Plot;
        var adder = myPlot.Plot.Add;
        var axisManager = myPlot.Plot.Axes;

        myPlot.Plot.XLabel("F1");
        myPlot.Plot.YLabel("F2");
        myPlot.Plot.Title("测试曲线");


        string cityFile = @$"R:\_CODE_\DOTNET\common.algorithm.core\Common.Algorithm.Core.Shared\_data_\pr76.txt";
        QuadTreeExecute.filePath = cityFile;
        QuadTreeExecute.dataNum = 50;
        var qte = new QuadTreeExecute();
         
        //------------------------------------
        ///绘制节点方框
        var rects = QuadTreeExecute.rects;
        foreach (var rect in rects)
        {
           var pntArr = rect.GenCornerPnt();
            Coordinates[] vertices = pntArr.Select( p=> new Coordinates(p.X,p.Y)  ).ToArray();
          
            var poly = adder.Polygon(vertices);
            poly.FillStyle.IsVisible = false;
        }
        //------------------------------------
        ///绘制物体点
        var pnts = QuadTreeExecute.geometryTests.Select(g => g.positon).ToList();
        foreach (var pnt in pnts)
        {
           var sct = adder.Scatter(pnt.X, pnt.Y);
            sct.Color = Colors.Black;
        }
        //------------------------------------
        axisManager.AutoScale();
         
        myPlot.Refresh();

        //Thread.Sleep(1000);

        //_renderTimer = new DispatcherTimer
        //{
        //    Interval = TimeSpan.FromMilliseconds(1)
        //};
        //_renderTimer.Tick += Render;
        //_renderTimer.Start();

        //Closed += (sender, args) =>
        //{
        //    _updateDataTimer?.Dispose();
        //    _renderTimer?.Stop();
        //};
    }

}